package negocio;

import java.util.ArrayList;

import java.util.List;


import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name="solicitudReposicion")
public class SolicitudReposicion 
{
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="id_SolicitudReposicion")
	private int id_SolicitudReposicion;
	
	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
	@JoinColumn(name="id_SolicitudReposicion", referencedColumnName="id_SolicitudReposicion")
	private List<ItemSolicitudReposicion> items = new ArrayList<>();
	
	@Column(name="sector", nullable=true)
	private String sector;

	public List<ItemSolicitudReposicion> getItems() 
	{
		return items;
	}

	public void setItems(List<ItemSolicitudReposicion> items) {
		this.items = items;
	}

	public int getId_SolicitudReposicion() {
		return id_SolicitudReposicion;
	}

	public void setId_SolicitudReposicion(int id_SolicitudReposicion) {
		this.id_SolicitudReposicion = id_SolicitudReposicion;
	}

	public String getSector() {
		return sector;
	}

	public void setSector(String sector) {
		this.sector = sector;
	}

	public void agregarItem(ItemSolicitudReposicion item) {
		items.add(item);
	}

	@Override
	public String toString() {
		return "SolicitudReposicion [id_SolicitudReposicion="
				+ id_SolicitudReposicion + ", items=" + items + ", sector="
				+ sector + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id_SolicitudReposicion;
		result = prime * result + ((items == null) ? 0 : items.hashCode());
		result = prime * result + ((sector == null) ? 0 : sector.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SolicitudReposicion other = (SolicitudReposicion) obj;
		if (id_SolicitudReposicion != other.id_SolicitudReposicion)
			return false;
		if (items == null) {
			if (other.items != null)
				return false;
		} else if (!items.equals(other.items))
			return false;
		if (sector == null) {
			if (other.sector != null)
				return false;
		} else if (!sector.equals(other.sector))
			return false;
		return true;
	}
}
